﻿/* ***************************************************************************************
 * Linq To SystemSearch
 * 
 *
 * This is an example of how extend LinQ using IQueruable and IOrderedQuerable interfaces.
 * 
 * User this code as you want,  is free.
 * 
 * Develop by: Mario Rodriguez
 * email: marior666@hotmail.com
 * 
 ********************************************************************************************/


using System.Collections.Generic;
using System.Linq.Expressions;
using System.Data;


namespace System.Search.Linq
{
    [Serializable]
    public class SystemIndexContext
    {
        public IEnumerator<T> Execute<T>(Expression expression)
        {


            if (expression == null)
                throw new ArgumentNullException("expression");

            SystemIndexDSQuery<T> query = SystemIndexDSQuery<T>.Parse(expression);

            return query.Execute();
        }

        internal DataSet ExecuteDataSet<T>(Expression expression)
        {



            return ExecuteQuery<T>(expression).DataSet;
        }

        internal Query<T> ExecuteQuery<T>(Expression expression)
        {


            if (expression == null)
                throw new ArgumentNullException("expression");

            SystemIndexDSQuery<T> query = SystemIndexDSQuery<T>.Parse(expression);

            return query.ExecuteQuery();
        }
    }
}
